package edu.cuny.baruch.cis9590.library.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="logins")
public final class Login {
    
    private int accessLevel;
    private String hashedPassword;
    private int id;
    private Date lastLogin;
    private int patronId;
    private String username;
    
    public Login() {
        
    }
    
    public Login(String username, String hashedPassword, int patronId) {
        this.username = username;
        this.hashedPassword = hashedPassword;
        this.patronId = patronId;
        this.accessLevel = 1;
        this.lastLogin = new Date();
    }
    
    @Column(name="access_level")
    public int getAccessLevel() {
        return accessLevel;
    }
    
    @Column(name="hashed_password")
    public String getHashedPassword() {
        return hashedPassword;
    }
    
    @Id
    @Column(name="login_id")
    @GeneratedValue(generator="increment")
    @GenericGenerator(name="increment", strategy="increment")
    public int getId() {
        return id;
    }
    
    @Column(name="last_login")
    public Date getLastLogin() {
        return lastLogin;
    }
    
    @Column(name="patron_id")
    public int getPatronId() {
        return patronId;
    }
    
    @Column(name="username")
    public String getUsername() {
        return username;
    }
    
    public void setAccessLevel(int accessLevel) {
        this.accessLevel = accessLevel;
    }
    
    public void setHashedPassword(String hashedPassword) {
        this.hashedPassword = hashedPassword;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public void setLastLogin(Date lastLogin) {
        this.lastLogin = lastLogin;
    }
    
    public void setPatronId(int patronId) {
        this.patronId = patronId;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
}
